Skip to content

Fix deserialization of unions #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

forest-benchling
Copy link
Collaborator

@forest-benchling forest-benchling commented Jan 28, 2021

NOTE: this has merge conflicts, because it's based off the benchling fork. I just wanted to get it up for review for visibility, I will change it to be based off triaxtec once you have bandwidth to review it.

Depends on #297

Deserialization of unions in from_dict was not working properly, because it failed to account for cases where the union property is None or Unset. This PR adds explicit checks for None or Unset.

In addition, the type of the value to deserialize was previously set to Any, which was masking type errors. In order to fix these type errors, I introduced a new concept of check_type_for_construct for each property, which allows the type to be checked before attempting deserialization.

In the future, I think we should refine the try/except pattern; it's not good practice to rely on a catch-all except when trying to deserialize each type within the union, because we don't know what exception was actually raised.

@forest-benchling
Copy link
Collaborator Author

Hi @dbanty , I know you're busy, but any chance you can get to review this PR and #316 this week? I will be on vacation for 2 weeks starting this Friday and it would be really nice to get it merged and prevent the already-accumulating merge conflicts.

@dbanty
Copy link
Collaborator

dbanty commented Feb 8, 2021

@forest-benchling sure thing, I'll make sure to take a look at them before then. Can you rebase open PRs against main so it's easier to see what changed? Also since I've decided not to go forward with #297, if this really does depend on that is it possible to separate them?

@forest-benchling
Copy link
Collaborator Author

@forest-benchling sure thing, I'll make sure to take a look at them before then. Can you rebase open PRs against main so it's easier to see what changed? Also since I've decided not to go forward with #297, if this really does depend on that is it possible to separate them?

Yes, I will try. Sorry, this will take some time because so much has happened in the meantime that the merge conflicts are a mess 😬

@eli-bl eli-bl deleted the forest-union-2 branch November 26, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants